package com.xyhua.hutooldemo.db;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.lang.func.VoidFunc1;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.Session;
import cn.hutool.json.JSONUtil;

import java.sql.SQLException;
import java.util.List;

/**
 * description: DbTest <br>
 * date: 2020/3/23 5:26 下午 <br>
 * author: huaxiansheng <br>
 * version: 1.0 <br>
 */
public class DbTest {

    public static void main(String[] args) throws SQLException {
//        Db.use().tx(
////                parameter -> {
//////                    parameter.execute();
//////                    parameter.query();
////                }
////        );
        List<Entity> query = Db.use().query("select * from user where User = ?","root");
//        List<Entity> query = Db.use().execute("select * from user where User = ?","root");
//        Db.use().insert(Entity.create("user").set());
//        Db.use().insertForGeneratedKey(Entity.create("user").set());
//        Db.use().update(Entity.create("user").set());
//        Db.use().del(Entity.create("user").set());
//        Db.use().find(Entity.create("user").set());

        Entity entity = query.get(0);
        Console.log(entity.getTableName());
        Console.log(entity.getFieldNames().toString());
        Console.log(entity.get("user"));
    }
}
